<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--sessionStorage-->
<button class="saveData">点我保存一个数据</button>
<button class="getData">点我获取一个数据</button>
<button class="removeData">点我清除一个数据</button>
<button class="clearData">点我清除所有数据</button>

<script>
    const btn1 = document.querySelector(".saveData")
    btn1.addEventListener("click", () => {
        sessionStorage.setItem("name", "陶品奇")
    })

    const btn2 = document.querySelector(".getData")
    btn2.addEventListener("click", () => {
        console.log(sessionStorage.getItem("name"))

    })

    const btn3 = document.querySelector(".removeData")
    btn3.addEventListener("click", () => {
        sessionStorage.removeItem("name")
    })


    const btn4 = document.querySelector(".clearData")
    btn4.addEventListener("click", () => {
        sessionStorage.clear()
    })
</script>
</body>
</html>
